home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nibble Magazine
/
nib05.dsk
/
TRAP 'EM.bas
< prev
Wrap
BASIC Source File
|
2023-02-26
|
10KB
|
218 lines
40 REM ********************************
41 REM ** TRAP 'EM **
42 REM ** BY ROB SMYTHE **
43 REM ** COPYRIGHT (C) 1980 BY **
44 REM ** MICRO-SPARC, INC. **
45 REM ** LINCOLN, MA 01773 **
46 REM ********************************
97 :
98 REM TITLE & INSTRUCTIONS
99 :
100 HOME
110 PRINT TAB( 14): FLASH : PRINT "TRAP'EM": NORMAL : PRINT : PRINT : PRINT "TRAP THE BEASTS BEFORE THEY GET YOU!": PRINT : PRINT : PRINT
120 PRINT TAB( 11);: INVERSE : PRINT "U";: NORMAL : PRINT " ";: INVERSE : PRINT "I";: NORMAL : PRINT " ";: INVERSE : PRINT "O": NORMAL
130 PRINT TAB( 12)" . . ."
140 PRINT TAB( 12)" . . . ": PRINT
150 PRINT TAB( 11);: INVERSE : PRINT "J";: NORMAL : PRINT " ";: INVERSE : PRINT "K";: NORMAL : PRINT " ";: INVERSE : PRINT "L": NORMAL
160 PRINT TAB( 12)" . . . "
170 PRINT TAB( 12)" . . .": PRINT
180 PRINT TAB( 11);: INVERSE : PRINT "M";: NORMAL : PRINT " ";: INVERSE : PRINT "<";: NORMAL : PRINT " ";: INVERSE : PRINT ">": NORMAL
190 PRINT
200 PRINT : PRINT "YOU .... + THEM .... *"
210 PRINT : PRINT : PRINT " BOX THEM IN COMPLETELY TO WIN. WIN BY PRESSING THE KEYS SHOWN ABOVE."
297 :
298 REM FILL ARRAY P% WITH SCREEN LOCATIONS
299 :
300 DIM P%(24,40)
310 FOR I = 1 TO 40: FOR J = 1 TO 8:P%(J,I) = 1023 +(J -1) *128 +I: NEXT J,I
320 FOR I = 1 TO 40: FOR J = 9 TO 16:P%(J,I) = 1063 +(J -9) *128 +I: NEXT J,I
330 FOR I = 1 TO 40: FOR J = 17 TO 24:P%(J,I) = 1103 +(J -17) *128 +I: NEXT J,I
397 :
398 REM SET-UP GAME
399 :
400 NORMAL : INPUT "NUMBER OF BEASTS (1,2, OR 3)? ";DF
410 HOME : CALL -868: INPUT "LEVEL OF DIFFICULTY (1,2,3)? ";EA: IF EA < >1 AND EA < >2 AND EA < >3 THEN 410
420 HOME :TIME = 0:X = FRE(0)
427 :
428 REM PLACE OBSTACLES
429 :
430 FOR I = 1 TO 40: POKE P%(1,I),32: POKE P%(23,I),32: NEXT
440 FOR I = 2 TO 22: POKE P%(I,1),32: POKE P%(I,40),32
450 NEXT I
460 FOR I = 1 TO 200:A% = INT( RND(1) *38 +2):B% = INT( RND(1) *21 +2)
470 POKE P%(B%,A%),24
480 NEXT
487 :
488 REM PLACE BEASTS
489 :
490 FOR I = 1 TO DF
500 V%(I) = INT( RND(1) *21 +2):H%(I) = INT( RND(1) *38 +2): IF PEEK(P%(V%(I),H%(I))) < >160 THEN 500
510 FOR J = 1 TO 20: POKE P%(V%(I),H%(I)),160: FOR K = 1 TO 20: NEXT K: POKE P%(V%(I),H%(I)),170: FOR K = 1 TO 20: NEXT K: NEXT J
520 NEXT I
527 :
528 REM FIND SPOT FOR HERO A REASONABLE DISTANCE FROM ALL BEASTS
529 :
530 V1% = INT( RND(1) *21 +2):H1% = INT( RND(1) *38 +2): IF PEEK(P%(V1%,H1%)) < >160 THEN 530
540 FOR I = 1 TO DF:D(I) = (V%(I) -V1%) ^2 +(H%(I) -H1%) ^2: NEXT
550 FOR I = 1 TO DF: IF D(I) <226 -30 *(DF -1) THEN I = DF: NEXT : GOTO 530
560 NEXT
570 FOR J = 1 TO 20: POKE P%(V1%,H1%),160: FOR K = 1 TO 20: NEXT K: POKE P%(V1%,H1%),171: FOR K = 1 TO 20: NEXT K: NEXT J
997 :
998 REM **** MAIN PROGRAM ****
999 :
1000 X = PEEK( -16384):Y = RND( - RND(1)): IF X <128 THEN 1000
1010 TIME = TIME +1: HTAB 1: VTAB 23: INVERSE : PRINT "TIME: ";: GOSUB 9000: PRINT TIME$;
1020 GOSUB 5000
1030 COUNT% = 0
1040 FOR N = 1 TO DF
1050 IF N = DF AND EA = 1 THEN GOSUB 5000
1060 GOSUB 6000
1070 IF N = 1 AND (EA < = 2) THEN GOSUB 5000
1080 NEXT
1090 GOTO 1010
4997 :
4998 REM CHECK FOR KEY PRESS
4999 :
5000 IF EA = 3 THEN 5030
5010 FOR J = 1 TO 15:X = PEEK( -16384): IF X >127 THEN J = 15
5020 NEXT J: GOTO 5040
5030 X = PEEK( -16384)
5040 IF X < = 127 THEN RETURN
5050 X$ = CHR$(X): GOSUB 5100
5060 RETURN
5097 :
5098 REM IDENTIFY KEY PRESSED
5099 :
5100 IF ASC(X$) = 203 THEN RETURN
5110 IF ASC(X$) = 201 THEN GOSUB 5300: RETURN
5120 IF ASC(X$) = 202 THEN GOSUB 5390: RETURN
5130 IF ASC(X$) = 204 THEN GOSUB 5480: RETURN
5140 IF ASC(X$) = 172 THEN GOSUB 5570: RETURN
5150 IF ASC(X$) = 174 THEN GOSUB 5660: RETURN
5160 IF ASC(X$) = 205 THEN GOSUB 5690: RETURN
5170 IF ASC(X$) = 206 THEN GOSUB 5690: RETURN
5180 IF ASC(X$) = 213 THEN GOSUB 5720: RETURN
5190 IF ASC(X$) = 207 THEN GOSUB 5750: RETURN
5200 RETURN
5297 :
5298 REM MOVE HERO AND PUSH OBSTACLES
5299 :
5300 IF PEEK(P%(V1% -1,H1%)) = 160 THEN POKE P%(V1%,H1%),160: POKE P%(V1% -1,H1%),171:V1% = V1% -1: RETURN
5310 Y = 0
5320 FOR I = V1% -1 TO 1 STEP -1: IF PEEK(P%(I,H1%)) = 160 THEN Y = I:I = 1: GOTO 5340
5330 IF PEEK(P%(I,H1%)) = 170 THEN I = 1
5340 NEXT
5350 IF Y = 0 THEN RETURN
5360 FOR I = Y TO V1% -2: POKE P%(I,H1%),24: NEXT
5370 POKE P%(I,H1%),171: POKE P%(V1%,H1%),160
5380 V1% = V1% -1: RETURN
5390 IF PEEK(P%(V1%,H1% -1)) = 160 THEN POKE P%(V1%,H1%),160: POKE P%(V1%,H1% -1),171:H1% = H1% -1: RETURN
5400 Y = 0
5410 FOR I = H1% -1 TO 1 STEP -1: IF PEEK(P%(V1%,I)) = 160 THEN Y = I:I = 1: GOTO 5430
5420 IF PEEK(P%(V1%,1)) = 170 THEN I = 1
5430 NEXT
5440 IF Y = 0 THEN RETURN
5450 FOR I = Y TO H1% -2: POKE P%(V1%,I),24: NEXT
5460 POKE P%(V1%,I),171: POKE P%(V1%,H1%),160
5470 H1% = H1% -1: RETURN
5480 IF PEEK(P%(V1%,H1% +1)) = 160 THEN POKE P%(V1%,H1%),160: POKE P%(V1%,H1% +1),171:H1% = H1% +1: RETURN
5490 Y = 0
5500 FOR I = H1% +1 TO 40:X% = PEEK(P%(V1%,I)): IF X% = 160 THEN Y = I:I = 40: GOTO 5520
5510 IF X% = 170 THEN I = 40
5520 NEXT
5530 IF Y = 0 THEN RETURN
5540 FOR I = Y TO H1% +2 STEP -1: POKE P%(V1%,I),24: NEXT
5550 POKE P%(V1%,I),171: POKE P%(V1%,H1%),160
5560 H1% = H1% +1: RETURN
5570 IF PEEK(P%(V1% +1,H1%)) = 160 THEN POKE P%(V1%,H1%),160: POKE P%(V1% +1,H1%),171:V1% = V1% +1: RETURN
5580 Y = 0
5590 FOR I = V1% +1 TO 23:X% = PEEK(P%(I,H1%)): IF X% = 160 THEN Y = I:I = 23: GOTO 5610
5600 IF X% = 170 THEN I = 23
5610 NEXT
5620 IF Y = 0 THEN RETURN
5630 FOR I = Y TO V1% +2 STEP -1: POKE P%(I,H1%),24: NEXT
5640 POKE P%(I,H1%),171: POKE P%(V1%,H1%),160
5650 V1% = V1% +1: RETURN
5660 IF PEEK(P%(V1% +1,H1% +1)) = 160 THEN POKE P%(V1%,H1%),160: POKE P%(V1% +1,H1% +1),171:V1% = V1% +1:H1% = H1% +1: RETURN
5670 VS% = 1:HS% = 1:X% = 22 -V1%: IF H1% >V1% +17 THEN I% = 39 -H1%
5680 GOTO 5780
5690 IF PEEK(P%(V1% +1,H1% -1)) = 160 THEN POKE P%(V1%,H1%),160: POKE P%(V1% +1,H1% -1),171:V1% = V1% +1:H1% = H1% -1: RETURN
5700 VS% = 1:HS% = -1:X% = 22 -V1%: IF H1% <24 -V1% THEN X% = H1% -2
5710 GOTO 5780
5720 IF PEEK(P%(V1% -1,H1% -1)) = 160 THEN POKE P%(V1%,H1%),160: POKE P%(V1% -1,H1% -1),171:V1% = V1% -1:H1% = H1% -1: RETURN
5730 VS% = -1:HS% = -1:X% = V1% -2: IF H1% <V1% THEN X% = H1% -2
5740 GOTO 5780
5750 IF PEEK(P%(V1% -1,H1% +1)) = 160 THEN POKE P%(V1%,H1%),160: POKE P%(V1% -1,H1% +1),171:V1% = V1% -1:H1% = H1% +1: RETURN
5760 VS% = -1:HS% = 1:X% = V1% -2: IF V1% >41 -H1% THEN X% = 39 -H1%
5770 GOTO 5780
5780 Y = 0
5790 FOR I = 1 TO X%
5800 IF PEEK(P%(V1% +VS% *I,H1% +HS% *I)) = 160 THEN Y = I:I = X%: GOTO 5820
5810 IF PEEK(P%(V1% +VS% *I,H1% +HS% *I)) = 170 THEN I = X%: NEXT I: RETURN
5820 NEXT I
5830 IF Y = 0 THEN RETURN
5840 FOR I = Y TO 2 STEP -1
5850 POKE P%(V1% +VS% *I,H1% +HS% *I),24
5860 NEXT
5870 POKE P%(V1%,H1%),160:V1% = V1% +VS%:H1% = H1% +HS%: POKE P%(V1%,H1%),171
5880 RETURN
5997 :
5998 REM MOVE BEASTS
5999 :
6000 FOR J = -1 TO 1: FOR K = -1 TO 1: IF PEEK(P%(V%(N) +J,H%(N) +K)) = 171 THEN J = 1:K = 1: NEXT K,J: GOTO 7000
6010 NEXT K,J
6020 Y = -1: IF V1% >V%(N) THEN Y = 1
6030 IF V1% = V%(N) THEN 6070
6040 X = RND(1): IF X <.6 THEN 6090
6050 Y = Y * -1: IF X >.75 THEN Y = 0
6060 GOTO 6090
6070 Y = 0:X = RND(1): IF X <.25 THEN Y = 1: GOTO 6090
6080 IF X >.75 THEN Y = -1
6090 V% = V%(N) +Y
6100 Y = -1: IF H1% >H%(N) THEN Y = 1
6110 IF H1% = H%(N) THEN 6150
6120 X = RND(1): IF X <.7 THEN 6170
6130 Y = Y * -1: IF Y >.8 THEN Y = 0
6140 GOTO 6170
6150 Y = 0:X = RND(1): IF X <.25 THEN Y = 1: GOTO 6170
6160 IF X >.75 THEN Y = -1
6170 H% = H%(N) +Y
6180 IF PEEK(P%(V%,H%)) = 160 THEN POKE P%(V%(N),H%(N)),160: POKE P%(V%,H%),170:V%(N) = V%:H%(N) = H%: RETURN
6190 IF PEEK(P%(V%,H%)) = 171 THEN V%(N) = V%:H%(N) = H%: GOTO 7000
6200 A = 1:B = -1: IF V1% >V%(N) THEN B = 1:A = -1
6210 FOR J = B TO A STEP A
6220 Z = 1:D = -1: IF H1% >H%(N) THEN Z = -1:D = 1
6230 FOR K = D TO Z STEP Z
6240 IF PEEK(P%(V%(N) +J,H%(N) +K)) = 171 THEN V% = V%(N) +J:H%(N) = H%(N) +K:J = A:K = Z: NEXT K,J: GOTO 7000
6250 IF PEEK(P%(V%(N) +J,H%(N) +K)) = 160 THEN POKE P%(V%(N),H%(N)),160:V%(N) = V%(N) +J:H%(N) = H%(N) +K: POKE P%(V%(N),H%(N)),170:J = A:K = Z: NEXT K,J: RETURN
6260 NEXT K,J:COUNT% = COUNT% +1: IF COUNT% = DF THEN 8000: REM PERSON WINS
6270 RETURN
6997 :
6998 REM LOSING GAME POST-MORTEM
6999 :
7000 POKE P%(V%(N),H%(N)),160: POP :N = DF: NEXT N
7010 POKE P%(V1%,H1%),170
7020 FOR I = 1 TO 10: POKE P%(V1%,H1%),160
7030 FOR J = 1 TO 20: NEXT
7040 PRINT CHR$(7);
7050 POKE P%(V1%,H1%),170: FOR J = 1 TO 40: NEXT J: NEXT I
7060 POKE ( -16368),0
7070 HTAB 1: VTAB 23
7080 GOSUB 9000
7090 POKE -16368,0
7100 PRINT "TIME: ";TIME$;: INPUT " YOU LOSE! PLAY AGAIN? ";A$: IF LEFT$(A$,1) < >"Y" THEN HOME : NORMAL : END
7110 GOTO 400
7997 :
7998 REM WINNING GAME POST-MORTEM
7999 :
8000 POP :N = DF: NEXT N
8010 FOR I = 1 TO 10: PRINT CHR$(7);: NEXT
8020 HTAB 1: VTAB 23: POKE -16368,0
8030 GOSUB 9000: PRINT "TIME: ";TIME$;" YOU WIN! ";: INPUT "PLAY AGAIN? ";A$: IF LEFT$(A$,1) < >"Y" THEN HOME : NORMAL : END
8040 GOTO 400
8997 :
8998 REM TIME DISPLAY FORMATTING
8999 :
9000 MI% = TIME/60:SE% = TIME -MI% *60:TIME$ = "": IF MI% >0 THEN TIME$ = STR$(MI%) +":"
9010 TIME$ = TIME$ + RIGHT$("00" + STR$(SE%),2)
9020 RETURN